//
//  MusicDetailViewController.m
//  OurRelaxDemo
//
//  Created by 王雅蓉 on 15/6/24.
//  Copyright (c) 2015年 于宾尧. All rights reserved.
//

#define ScreenHeight [UIScreen mainScreen].bounds.size.height
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define Tablebar 49
#define GapOfImage 10.0

#import "MusicDetailViewController.h"
#import "MusicDetailTableViewCell.h"
#import "MusicDetailHeaderView.h"

#import "MusicListViewController.h"
#import "MusicPlayViewController.h"

#import "AFNConnect.h"

#import "MusicForSonglist.h"

#import <UIImageView+WebCache.h>

#import "MONActivityIndicatorView.h"
@interface MusicDetailViewController ()<UITableViewDataSource, UITableViewDelegate, MONActivityIndicatorViewDelegate>
{
    UIImageView *playIV;
}

@property (nonatomic, retain) UIButton *playButton;
@property (nonatomic, retain) UIButton *nextButton;

@property (nonatomic, retain) UILabel *titleL;
@property (nonatomic, retain) UILabel *subTitleL;
@property (nonatomic, retain) UILabel *duringL;

@property (nonatomic, retain) MusicDetailHeaderView *musicHV;
@property (nonatomic, retain) UIPageControl *pageControl;

@property (nonatomic, retain) MusicDetailTableViewCell *myCell;

@property (nonatomic, retain) NSIndexPath *myIndexPath;

@property (nonatomic, retain) MusicDetailModel *nextMusicDetail;
@property (nonatomic, copy) NSString *nextID;

@property (nonatomic, retain)MONActivityIndicatorView *active;

@end

@implementation MusicDetailViewController

-(void)dealloc
{
    [_myTableView release];
    
    [super dealloc];
}

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        _myMusicDetail = [[MusicDetailModel alloc] init];
        self.mySonglistArray = [NSMutableArray array];
        self.nextMusicDetail = [[MusicDetailModel alloc] init];
        [self setSubviews];
    }
    
    return self;
}

-(void)setSubviews
{
    self.navigationItem.title = self.titleStr;
    
    //UIColor *bg_color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_hudie1.jpg"]];
    //self.view.backgroundColor = bg_color;
    self.view.backgroundColor = [UIColor whiteColor];
    

    self.myTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStylePlain];
    //self.myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 20 + 44, ScreenWidth, ScreenHeight - 64) style:UITableViewStylePlain];

    self.myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64 - 49) style:UITableViewStylePlain];

    self.myTableView.dataSource = self;
    self.myTableView.delegate = self;
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.myTableView.backgroundColor = [UIColor clearColor];
    
    self.musicHV = [[MusicDetailHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)];
    //self.musicHV.backgroundColor = [UIColor clearColor];
    self.musicHV.bounces = NO;
    self.musicHV.pagingEnabled = YES;
    self.musicHV.showsHorizontalScrollIndicator = NO;
    self.musicHV.contentOffset = CGPointMake(self.view.frame.size.width, 0);
    self.myTableView.tableHeaderView = self.musicHV;
    _musicHV.delegate = self;
    [self.view addSubview:self.myTableView];
    [_myTableView release];
    _myTableView.rowHeight = 60;
    
    [self setTabBar];
    
    self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(self.musicHV.frame.size.width / 2.0 - 50, self.musicHV.frame.size.height - 40, 100, 40)];
    //self.pageControl.backgroundColor = [UIColor redColor];
    self.pageControl.backgroundColor = [UIColor clearColor];
    [self.myTableView addSubview:self.pageControl];
    [_pageControl release];
    
    self.pageControl.numberOfPages = 3;
    self.pageControl.currentPage = 1;
    
    //self.pageControl.currentPageIndicatorTintColor = [UIColor redColor];
    //self.pageControl.pageIndicatorTintColor = [UIColor blackColor];
    
    [self.pageControl addTarget:self action:@selector(pageAction:) forControlEvents:UIControlEventValueChanged];

}
#pragma mark 协议方法
- (UIColor *)activityIndicatorView:(MONActivityIndicatorView *)activityIndicatorView
      circleBackgroundColorAtIndex:(NSUInteger)index {
    CGFloat red   = (arc4random() % 256)/255.0;
    CGFloat green = (arc4random() % 256)/255.0;
    CGFloat blue  = (arc4random() % 256)/255.0;
    CGFloat alpha = 1.0f;
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.translucent = NO;
    
    if ([MusicDetailShareHandle shareListDataHandle].statusMusic != nil) {
        
        _titleL.text = [MusicDetailShareHandle shareListDataHandle].statusMusic.song_name;
        _subTitleL.text = [MusicDetailShareHandle shareListDataHandle].statusMusic.singer_name;
    }

#pragma 改
    if ([TagHandle shareTagHandle].isPlaying) {
        
        [_playButton setBackgroundImage:[UIImage imageNamed:@"play_bar_pause.png"] forState:UIControlStateNormal];
    } else {
        
        [_playButton setBackgroundImage:[UIImage imageNamed:@"play_bar_play.png"] forState:UIControlStateNormal];
    }
    
    [self.myTableView reloadData];

}
- (void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBar.translucent = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //self.view.frame = CGRectMake(375, 0, 375, 667);
    self.active = [[MONActivityIndicatorView alloc] init];
    _active.delegate = self;
    _active.numberOfCircles = 5;
    _active.radius = 7;
    _active.internalSpacing = 10;
    _active.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2);
    [_active startAnimating];
    [self.view addSubview:_active];
    
    
    [self getSonglist:[MusicDetailShareHandle shareListDataHandle].playingMusic.msg_id indexPath:[MusicDetailShareHandle shareListDataHandle].nextPageIndexPath];
    //NSLog(@"5656565656 = %@", _mySonglist);
    //NSLog(@"mySonglist = %@", _mySonglistArray);
    
    //[Player shareDataHandle].player.delegate = self;
    [self.myTableView reloadData];

}

-(void)setTabBar
{
    UILabel *tableBar = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenHeight - Tablebar - 63, ScreenWidth, Tablebar)];
    tableBar.text = @"tableBar";
//    tableBar.backgroundColor = [UIColor yellowColor];
    tableBar.backgroundColor = [UIColor whiteColor];
    tableBar.textAlignment = NSTextAlignmentCenter;
    tableBar.textColor = [UIColor whiteColor];
    tableBar.userInteractionEnabled = YES;
    [self.view addSubview:tableBar];
    //NSLog(@"SETtabbar");
    
    UIButton *listButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //listButton.backgroundColor = [UIColor redColor];
    [listButton setBackgroundImage:[UIImage imageNamed:@"list_menu_playlist.png"] forState:UIControlStateNormal];
    listButton.frame = CGRectMake(ScreenWidth - tableBar.frame.size.height + 10, 10, 30, 30);
    [listButton addTarget:self action:@selector(listButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [tableBar addSubview:listButton];
    
    playIV = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, tableBar.frame.origin.y, tableBar.frame.size.height, tableBar.frame.size.height)];
    //playIV.backgroundColor = [UIColor yellowColor];
    playIV.image = [UIImage imageNamed:@"musiccircle_userinfo_avatar_default.png"];
    playIV.userInteractionEnabled = YES;
    [self.view addSubview:playIV];
    [playIV release];
    
    self.titleL = [[UILabel alloc] initWithFrame:CGRectMake(playIV.frame.size.width + 5, playIV.frame.origin.y, 150, tableBar.frame.size.height / 3 + 10)];
    //_titleL.backgroundColor = [UIColor yellowColor];
    _titleL.font = [UIFont systemFontOfSize:14.0];
    _titleL.textColor = [UIColor darkGrayColor];
    [self.view addSubview:_titleL];
    [_titleL release];
    
    self.subTitleL = [[UILabel alloc] initWithFrame:CGRectMake(_titleL.frame.origin.x, _titleL.frame.origin.y + _titleL.frame.size.height, _titleL.frame.size.width, _titleL.frame.size.height / 2)];
    //_subTitleL.backgroundColor = [UIColor cyanColor];
    _subTitleL.font = [UIFont systemFontOfSize:12.0];
    _subTitleL.textColor = [UIColor grayColor];
    [self.view addSubview:_subTitleL];
    [_subTitleL release];
    /*
    self.duringL = [[UILabel alloc] initWithFrame:CGRectMake(_titleL.frame.origin.x, _subTitleL.frame.origin.y + _subTitleL.frame.size.height, _titleL.frame.size.width, _subTitleL.frame.size.height)];
    //_duringL.backgroundColor = [UIColor redColor];
    _duringL.font = [UIFont systemFontOfSize:10.0];
    _duringL.textColor = [UIColor grayColor];
    _duringL.text = @"00:00 - 00:00";
    [self.view addSubview:_duringL];
    [_duringL release];*/
    
    self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.playButton setBackgroundImage:[UIImage imageNamed:@"play_bar_play.png"] forState:UIControlStateNormal];
    //[playButton setBackgroundImage:[UIImage imageNamed:@"play_bar_pause.png"] forState:UIControlStateHighlighted];
    if ([[UIScreen mainScreen] bounds].size.width >= 375) {
        
        self.playButton.frame = CGRectMake(_titleL.frame.origin.x + _titleL.frame.size.width + 40, _titleL.frame.origin.y, tableBar.frame.size.height, tableBar.frame.size.height);
        
    } else {
    
        self.playButton.frame = CGRectMake(_titleL.frame.origin.x + _titleL.frame.size.width, _titleL.frame.origin.y + 5, tableBar.frame.size.height - 10, tableBar.frame.size.height - 10);
    }
    [self.playButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.playButton];
    
    self.nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.nextButton setBackgroundImage:[UIImage imageNamed:@"play_bar_play_next.png"] forState:UIControlStateNormal];
    if ([[UIScreen mainScreen] bounds].size.width >= 375) {
        
        self.nextButton.frame = CGRectMake(self.playButton.frame.origin.x + self.playButton.frame.size.width, self.playButton.frame.origin.y, self.playButton.frame.size.width, self.playButton.frame.size.height);
        
    } else {
    
        self.nextButton.frame = CGRectMake(self.playButton.frame.origin.x + self.playButton.frame.size.width, self.playButton.frame.origin.y, tableBar.frame.size.height - 10, tableBar.frame.size.height - 10);
    }
    [self.nextButton addTarget:self action:@selector(nextAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.nextButton];
    
    UITapGestureRecognizer *imageTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [playIV addGestureRecognizer:imageTap];
    [imageTap release];
}

-(void)pageAction:(UIPageControl *)pageC
{
    [self.musicHV setContentOffset:CGPointMake(ScreenWidth * pageC.currentPage, 0) animated:YES];
}

-(void)playAction:(UIButton *)button
{
    [TagHandle shareTagHandle].isPlaying = ![TagHandle shareTagHandle].isPlaying;
    if ([TagHandle shareTagHandle].isPlaying) {
#pragma 改
        if ([Player shareDataHandle].oldIndex != [Player shareDataHandle].playingIndex) {
            
            [[Player shareDataHandle] PlayForArray];
        } else {
            [[Player shareDataHandle].player resume];
        }
        [self.playButton setBackgroundImage:[UIImage imageNamed:@"play_bar_pause.png"] forState:UIControlStateNormal];
        
    } else {
        
        [[Player shareDataHandle].player pause];
        [self.playButton setBackgroundImage:[UIImage imageNamed:@"play_bar_play.png"] forState:UIControlStateNormal];
    }


}

-(void)nextAction:(UIButton *)button
{
    [[Player shareDataHandle] NextPlay];
    
    _titleL.text = [MusicDetailShareHandle shareListDataHandle].statusMusic.song_name;
    _subTitleL.text = [MusicDetailShareHandle shareListDataHandle].statusMusic.singer_name;
    
    NSMutableArray *durationArray = (NSMutableArray *)[MusicDetailShareHandle shareListDataHandle].statusMusic.url_list;
    NSMutableDictionary *durationDic = [durationArray firstObject];
    NSString *durationStr = [NSString stringWithFormat:@"00:00 - %@", [durationDic objectForKey:@"duration"]];
    _duringL.text = durationStr;
    
}

-(void)listButtonAction
{
    MusicListViewController *musicListVC = [[MusicListViewController alloc] init];
    
    [self presentViewController:musicListVC animated:YES completion:^{
        
        
    }];
}

-(void)tapAction:(UITapGestureRecognizer *)tapGesture
{
    MusicPlayViewController *musicPlayVC = [[MusicPlayViewController alloc] init];
    
    UINavigationController *playNC = [[UINavigationController alloc] initWithRootViewController:musicPlayVC];
    
    //[self.navigationController pushViewController:playNC animated:YES];
    [self presentViewController:playNC animated:YES completion:^{
        
        
    }];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //[[Player shareDataHandle].player stop];
    //[MusicDetailShareHandle shareListDataHandle].listShareArray = _mySonglistArray;
    //播放
    [Player shareDataHandle].playingIndex = indexPath.row;
    
    [Player shareDataHandle].currentUrlArray = [MusicDetailShareHandle shareListDataHandle].listURLArray;
    [[Player shareDataHandle] PlayForArray];
    
    //点击列表播放
    if ([TagHandle shareTagHandle].isPlaying) {
        
        [self.playButton setBackgroundImage:[UIImage imageNamed:@"play_bar_pause.png"] forState:UIControlStateNormal];
        
    } else {
        
        [self.playButton setBackgroundImage:[UIImage imageNamed:@"play_bar_play.png"] forState:UIControlStateNormal];
    }
    
    // ***********************************
    MusicForSonglist *tmpSongList = (MusicForSonglist *)[[MusicDetailShareHandle shareListDataHandle].listShareArray objectAtIndex:indexPath.row];
    [MusicDetailShareHandle shareListDataHandle].statusMusic = tmpSongList;
    //NSLog(@"232323 %@", tmpSongList);
    _titleL.text = tmpSongList.song_name;
    _subTitleL.text = tmpSongList.singer_name;
    
    NSMutableArray *durationArray = (NSMutableArray *)tmpSongList.url_list;
    NSMutableDictionary *durationDic = [durationArray firstObject];
    NSString *durationStr = [NSString stringWithFormat:@"00:00 - %@", [durationDic objectForKey:@"duration"]];
    _duringL.text = durationStr;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _mySonglistArray.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (_mySonglistArray.count <= 6) {
        
        return 80;
    } else {
    
        return 0;
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.myIndexPath = indexPath;
    static NSString *cellIdentifier = @"musicDetailCell";
    
    self.myCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
    if (_myCell == nil) {
        
        self.myCell = [[MusicDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
        _myCell.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    
    //NSLog(@"%@",_songListArray);
    //_myCell.songList = [_songListArray objectAtIndex:indexPath.row];
    _myCell.songList = [_mySonglistArray objectAtIndex:indexPath.row];
    
    return _myCell;
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    _pageControl.currentPage = _musicHV.contentOffset.x / ScreenWidth;
}

-(void)setMySonglistArray:(NSMutableArray *)mySonglistArray
{
    if (_mySonglistArray != mySonglistArray) {
        
        [_mySonglistArray release];
        _mySonglistArray = [mySonglistArray retain];
        
    }
    
    //NSLog(@"mySonglist = %@", mySonglistArray);
    //_myCell.songList = mySonglist;
}

-(void)setMyMusicDetail:(MusicDetailModel *)myMusicDetail
{
    if (_myMusicDetail != myMusicDetail) {
        
        [_myMusicDetail release];
        _myMusicDetail = [myMusicDetail retain];
        
    }
    //NSLog(@"%@",myMusicDetail.pics);
    //self.musicHV.musicDetail = [[MusicDetailModel alloc] init];
    //NSLog(@"111111");
    self.musicHV.musicDetailForHV = myMusicDetail;
    //NSLog(@"123123123 %@",myMusicDetail.pics);
}

-(void)setDetailSonglist:(MusicForSonglist *)detailSonglist
{
    if (_detailSonglist != detailSonglist) {
        
        [_detailSonglist release];
        _detailSonglist = [detailSonglist retain];
        
    }
    
    //NSLog(@"%@",detailSonglist.url_list);
    _titleL.text = [MusicDetailShareHandle shareListDataHandle].statusMusic.song_name;
    _subTitleL.text = [MusicDetailShareHandle shareListDataHandle].statusMusic.singer_name;
    
}

// ******************************* id **********************************
//获取下一界面的id
-(void)getSonglist:(NSString *)songID indexPath:(NSIndexPath *)indexPath;
{
    NSMutableArray *songIDArray = [NSMutableArray array];
    //NSLog(@"232323 %@",self.nextId);
    NSString *urlStr = [NSString stringWithFormat:@"http://v1.ard.q.itlily.com/share/user_timeline?msg_ids=%%5B%@%%5D&app=ttpod&v=v7.9.4.2015052918&uid=&mid=iPhone7%%2C2&f=f320&s=s310&imsi=&hid=&splus=8.3&active=1&net=2&openudid=0dd348dbab822aeed85fbb8aa4c013f995b389ff&idfa=40C53D22-7D7E-4CE4-B53C-647128B9A9EA&utdid=VXlbm0s4gVcDAKj0hGWGx2OY&alf=201200&bundle_id=com.ttpod.music", songID];
    //NSLog(@"dfsdfsdfseee  %@", urlStr);
    [AFNConnect AFNConnectWithUrl:urlStr key:@"data" connectBlock:^(id data) {
        
        //NSLog(@"====== %@",data);
        self.nextMusicDetail = (MusicDetailModel *)[MusicDetailModel musicDetailWithArray:data];
        //NSLog(@"454545454 %@", _nextMusicDetail.pics);
        
        for (NSMutableDictionary *dic in (NSMutableArray *)_nextMusicDetail.songlist) {
            
            [songIDArray addObject:[dic objectForKey:@"song_id"]];
            
        }
        //NSLog(@"67676767=%ld",songIDArray.count);
        
        NSString *tmp = songIDArray[0];
        for (int i = 1; i < songIDArray.count; i++) {
            
            self.nextID = [NSString stringWithFormat:@"%@,%@", tmp, songIDArray[i]];
            tmp = _nextID;
            
        }
        //NSLog(@"%@", _nextID);
        
        [self getSongData:indexPath];
    }];
    
}

-(void)getSongData:(NSIndexPath *)indexPath
{
    NSString *urlStr = [NSString stringWithFormat:@"http://ting.hotchanson.com/songs/downwhite?song_id=%@&app=ttpod&v=v7.9.4.2015052918&uid=&mid=iPhone7%%2C2&f=f320&s=s310&imsi=&hid=&splus=8.3&active=1&net=2&openudid=0dd348dbab822aeed85fbb8aa4c013f995b389ff&idfa=40C53D22-7D7E-4CE4-B53C-647128B9A9EA&utdid=VXlbm0s4gVcDAKj0hGWGx2OY&alf=201200&bundle_id=com.ttpod.music", self.nextID];
    //NSLog(@"%@",urlStr);
    [AFNConnect AFNConnectWithUrl:urlStr key:@"data" connectBlock:^(id data) {
        
        //NSLog(@"DetailData = %@", data);
        self.mySonglistArray = [MusicForSonglist songListWithArray:data];
        //NSLog(@"songList = %@", [_mySonglistArray objectAtIndex:0]);
        //NSLog(@"===== %@",data);
        //得到musicForSongList数组
        [[MusicDetailShareHandle shareListDataHandle] sendSongListModel:_mySonglistArray];
        //NSLog(@"dfsdfdf %@",[MusicDetailShareHandle shareListDataHandle].listShareArray);
        
        //获取播放链接数组
        NSMutableArray *urlSonglist = [NSMutableArray array];
        for (MusicForSonglist *tmpSonglist in [MusicDetailShareHandle shareListDataHandle].listShareArray) {
            
            //NSLog(@" hjkl %@",tmpSonglist.url_list);
            if (((NSMutableArray *)tmpSonglist.url_list).count != 0) {
                
                NSMutableDictionary *dic = [((NSMutableArray *)tmpSonglist.url_list) objectAtIndex:0];
                NSString *tmpUrl = [dic objectForKey:@"url"];
                [urlSonglist addObject:tmpUrl];
                //NSLog(@"url = %@",tmpUrl);
            } else {
            
                
            }
        }
        [MusicDetailShareHandle shareListDataHandle].listURLArray = urlSonglist;
        
        if (indexPath.section == 0) {
            
            NSString *detailTitle = ((MusicModel *)[MusicDetailShareHandle shareListDataHandle].messageArray[indexPath.row]).title;
            
            //NSLog(@"%ld",indexPath.row);
            
            self.titleStr = detailTitle;
            self.mySonglistArray = _mySonglistArray;
            self.myMusicDetail = self.nextMusicDetail;
            //[self.myDelegate pushToDetail:detailTitle andArray:tmpSonglistArray andDetailModel:self.nextMusicDetail];
            //NSLog(@"songlistArray = %@",self.mySonglistArray);
            
            
        } else {
            
            NSMutableDictionary *tmpDic = [MusicDetailShareHandle shareListDataHandle].weekDic;
            //NSString *weekKey = [tmpDic.allKeys objectAtIndex:indexPath.section - 1];
            NSString *weekKey = [[MusicDetailShareHandle shareListDataHandle].weekForDetailArray objectAtIndex:indexPath.section - 1];
            NSMutableArray *tmpArray = [tmpDic objectForKey:weekKey];
            //NSLog(@"tmpArray = %@", tmpArray);
            NSString *songTitle = ((MusicModel *)tmpArray[indexPath.row]).title;
            self.titleStr = songTitle;
            self.myMusicDetail = self.nextMusicDetail;
            self.mySonglistArray = _mySonglistArray;
            //[self.myDelegate pushToDetail:songTitle andArray:tmpSonglistArray andDetailModel:self.nextMusicDetail];
            //NSLog(@"songlistArray = %@",self.songListArray);
        }
        
        [self.myTableView reloadData];
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
